package cn.terminus.data.customer.contractrentdiscountclause.impl;

import cn.terminus.common.customer.bean.contractrentdiscountclause.dto.*;
import cn.terminus.data.customer.contractrentdiscountclause.dao.ContractRentDiscountClauseDao;
import cn.terminus.data.customer.contractrentdiscountclause.mapper.ContractRentDiscountClauseMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 合同优惠条款(ContractRentDiscountClause)表服务实现类
 *
 * @author makejava
 * @since 2021-07-21 11:15:29
 */
@Repository
public class ContractRentDiscountClauseDaoImpl implements ContractRentDiscountClauseDao {
    @Resource
    private ContractRentDiscountClauseMapper contractRentDiscountClauseMapper;

    @Override
    public Integer add(ContractRentDiscountClauseNewDto dto) {
        return contractRentDiscountClauseMapper.add(dto);
    }

    @Override
    public Integer update(ContractRentDiscountClauseEditDto dto) {
        return contractRentDiscountClauseMapper.update(dto);
    }

    @Override
    public List<ContractRentDiscountClauseResultDto> gets(ContractRentDiscountClauseGetsDto dto) {
        return contractRentDiscountClauseMapper.gets(dto);
    }

    @Override
    public List<ContractRentDiscountClauseResultDto> query(ContractRentDiscountClauseQueryDto dto) {
        return contractRentDiscountClauseMapper.query(dto);
    }

    @Override
    public Integer delete(ContractRentDiscountClauseDeleteDto dto) {
        return contractRentDiscountClauseMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<ContractRentDiscountClauseResultDto> page(ContractRentDiscountClauseQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<ContractRentDiscountClauseResultDto> result = (Page<ContractRentDiscountClauseResultDto>) contractRentDiscountClauseMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), ContractRentDiscountClauseResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer insertBatch(List<ContractRentDiscountClauseNewDto> dtos) {
        return contractRentDiscountClauseMapper.insertBatch(dtos);
    }

    @Override
    public Integer deleteWithContractId(Long id) {
        return contractRentDiscountClauseMapper.deleteWithContractId(id);
    }
}
